#线性回归算法预测儿童身高
import  copy
import numpy as np
from sklearn import  linear_model

x= np.array([[1,0,180,165,175,165,170,165],
            [3,0,180,165,175,165,173,165],
            [4,0,180,165,175,165,170,165],
            [6,0,180,165,175,165,170,165],
            [8,1,180,165,175,167,170,165],
            [10,0,180,165,175,165,170,165],
            [11,0,180,165,175,165,170,165],
            [12,0,180,165,175,165,170,165],
            [13,1,180,165,175,165,170,165],
            [14,0,180,165,175,165,170,165],
            [17,0,170,165,175,165,170,165],
])

y = np.array([60,90,100,110,130,140,150,164,\
              160,163,168])
lr = linear_model.LinearRegression()
lr.fit(x,y)

xs =np.array([[10,0,180,165,175,165,170,165],
              [17,1,173,153,175,161,170,161],
              [34,0,170,165,170,165,170,165]
              ])

for item in xs:
    item1 = copy.deepcopy(item)
    if item1[0] >18:
        item1[0] =18
    print(item,':',lr.predict(item1.reshape(1,-1)))